<?php
namespace Modules\ShopApi\Http\Controllers\v1;
use Illuminate\Http\Request;
use Modules\ShopApi\Http\Requests\IDMustBePositiveIntRequest;
use Modules\ShopApi\Http\Requests\AddCartRequest;
use Modules\ShopApi\Models\ShopCart as ShopCartModel;
class CartController extends CommonController
{
	/**
	 * @name  加入购物车
	 * @method  POST	
	 * @param product_id 商品id
	 * @param num 购买数量
	 * @param specs_id 商品规格id
	 * @return  JSON
	 */
    public function add_cart(AddCartRequest $request)
    { 
        return (new ShopCartModel())->add_cart($request->all());
    }
	/**
	 * @name  购物车列表
	 * @method  GET	
	 * @return  JSON
	 */
    public function cart_list()
    { 
        return (new ShopCartModel())->cart_list();
    }
	/**
	 * @name  购物车加
	 * @method  PUT	
	 * @param id 购物车表id
	 * @return  JSON
	 */
    public function cart_add(IDMustBePositiveIntRequest $request)
    { 
        return (new ShopCartModel())->cart_add($request->get('id'));
    }
	/**
	 * @name  购物车减
	 * @method  PUT	
	 * @param id 购物车表id
	 * @return  JSON
	 */
    public function cart_subtract(IDMustBePositiveIntRequest $request)
    { 
        return (new ShopCartModel())->cart_subtract($request->get('id'));
    }
	/**
	 * @name  购物车删除
	 * @method  DELETE	
	 * @param id 购物车表id
	 * @return  JSON
	 */
    public function cart_delete(IDMustBePositiveIntRequest $request)
    { 
        return (new ShopCartModel())->cart_delete($request->get('id'));
    }
}
